/*
 ============================================================================
 Name		: NiContainer.cpp
 Author	  : nmj
 Version	 : 1.0
 Copyright   : Copyright ? 2010 - 2010 NMJ. All Rights Reserved.
 Description : CNiContainer implementation
 ============================================================================
 */

#include <eiklabel.h>
#include "NiContainer.h"

CNiContainer::CNiContainer()
{
	// No implementation required
}

CNiContainer::~CNiContainer()
{
	delete iLabel;
}

CNiContainer* CNiContainer::NewLC(const TRect& aRect,CCoeControl* aParent)
{
	CNiContainer* self = new (ELeave) CNiContainer();
	CleanupStack::PushL(self);
	self->ConstructL(aRect,aParent);
	return self;
}

CNiContainer* CNiContainer::NewL(const TRect& aRect,CCoeControl* aParent)
{
	CNiContainer* self = CNiContainer::NewLC(aRect,aParent);
	CleanupStack::Pop(); // self;
	return self;
}

void CNiContainer::ConstructL(const TRect& aRect,CCoeControl* aParent)
{
	SetContainerWindowL(*aParent);
	_LIT(KTextHelloWorld, "hello world");
	iLabel = new (ELeave) CEikLabel;
	iLabel->SetContainerWindowL(*this);
	iLabel->SetTextL(KTextHelloWorld);
	SetRect( aRect );
}

void CNiContainer::SizeChanged()
{  
    iLabel->SetExtent( TPoint(0,0), iLabel->MinimumSize());
}

TInt CNiContainer::CountComponentControls()const
{
	return 1;
}

CCoeControl* CNiContainer::ComponentControl(TInt aIndex)const
{
	switch ( aIndex )
	{
	case 0:
	    return iLabel;
	default:
	    return NULL;
	}
}

void CNiContainer::SetTextL(const TDesC& aText)
{
	iLabel->SetTextL(aText);	
}
